﻿
namespace OpenPms.Data;

public enum EWXMsgType
{
    Ota新订成功消息,
    Ota新订失败消息,
    Ota取消消息,
    入住消息,
    退房消息,
    客人消息
}
[EntityTypeConfiguration<TWXMsgConfig, TWXMsg>()]
public class TWXMsg
{
    public int HotelId { get; set; }
    [Display(Name = "消息类别")]
    public EWXMsgType WXMsgType { get; set; }
    public string? UserIds { get; set; }
    [StringLength(32)]
    public string CorpId { get; set; } = default!;
    [NotMapped]
    [Display(Name = "接收人")]
    public string DisplayUserIds => string.Join(" | ", UserIds?.Split('|')?.Select(ii => $"<ww-open-data type='userName' openid='{ii}'></ww-open-data>") ?? []);
}

public class TWXMsgConfig : IEntityTypeConfiguration<TWXMsg>
{
    public void Configure(EntityTypeBuilder<TWXMsg> builder)
    {
        builder.HasKey(ii => new { ii.HotelId, ii.WXMsgType });
    }
}
